package com.binarysoft.service.operlog;

import com.binarysoft.service.operlog.OperLog;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface OperLogMapper {
    @Delete({
        "delete from OPER_LOG",
        "where LOGID = #{logid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(long logid);

    @Insert({
        "insert into OPER_LOG (LOGID, OPERNAME, ",
        "OPERDESC, OPERSTATUS, ",
        "USER_ID, OPER_TIME)",
        "values (#{logid,jdbcType=INTEGER}, #{opername,jdbcType=VARCHAR}, ",
        "#{operdesc,jdbcType=VARCHAR}, #{operstatus,jdbcType=VARCHAR}, ",
        "#{userId,jdbcType=VARCHAR}, #{operTime,jdbcType=DATE})"
    })
    int insert(OperLog record);

    @InsertProvider(type=OperLogSqlProvider.class, method="insertSelective")
    int insertSelective(OperLog record);

    @Select({
        "select",
        "LOGID, OPERNAME, OPERDESC, OPERSTATUS, USER_ID, OPER_TIME",
        "from OPER_LOG",
        "where LOGID = #{logid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="LOGID", property="logid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="OPERNAME", property="opername", jdbcType=JdbcType.VARCHAR),
        @Result(column="OPERDESC", property="operdesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="OPERSTATUS", property="operstatus", jdbcType=JdbcType.VARCHAR),
        @Result(column="USER_ID", property="userId", jdbcType=JdbcType.VARCHAR),
        @Result(column="OPER_TIME", property="operTime", jdbcType=JdbcType.DATE)
    })
    OperLog selectByPrimaryKey(long logid);

    @UpdateProvider(type=OperLogSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(OperLog record);

    @Update({
        "update OPER_LOG",
        "set OPERNAME = #{opername,jdbcType=VARCHAR},",
          "OPERDESC = #{operdesc,jdbcType=VARCHAR},",
          "OPERSTATUS = #{operstatus,jdbcType=VARCHAR},",
          "USER_ID = #{userId,jdbcType=VARCHAR},",
          "OPER_TIME = #{operTime,jdbcType=DATE}",
        "where LOGID = #{logid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(OperLog record);
}